<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="90px">
      <el-form-item label="公司代码" prop="factoryCode">
        <el-input
          v-model="queryParams.factoryCode"
          placeholder="请输入公司代码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="公司名称" prop="factoryName">
        <el-input
          v-model="queryParams.factoryName"
          placeholder="请输入公司名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="WMS子图号" prop="wmsChildNo">
        <el-input
          v-model="queryParams.wmsChildNo"
          placeholder="请输入WMS子图号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="子图号" prop="itemChildNo">
        <el-input
          v-model="queryParams.itemChildNo"
          placeholder="请输入子图号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物料号" prop="materialNo">
        <el-input
          v-model="queryParams.materialNo"
          placeholder="请输入物料号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="名称" prop="itemName">
        <el-input
          v-model="queryParams.itemName"
          placeholder="请输入名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="公司代码" prop="manCode">
        <el-input
          v-model="queryParams.manCode"
          placeholder="请输入公司代码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="公司名称" prop="manName">
        <el-input
          v-model="queryParams.manName"
          placeholder="请输入公司名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物料正式属性" prop="materialFormAttr">
        <el-input
          v-model="queryParams.materialFormAttr"
          placeholder="请输入物料正式属性"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物料属性" prop="materialAttr">
        <el-input
          v-model="queryParams.materialAttr"
          placeholder="请输入物料属性"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物料大类号" prop="materialCategory">
        <el-input
          v-model="queryParams.materialCategory"
          placeholder="请输入物料大类号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="送货包装编码" prop="delPackageCode">
        <el-input
          v-model="queryParams.delPackageCode"
          placeholder="请输入送货包装编码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物料图片" prop="materialPhoto">
        <el-input
          v-model="queryParams.materialPhoto"
          placeholder="请输入物料图片"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物料尺寸" prop="materialSize">
        <el-input
          v-model="queryParams.materialSize"
          placeholder="请输入物料尺寸"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="包装容量" prop="pacCapacity">
        <el-input
          v-model="queryParams.pacCapacity"
          placeholder="请输入包装容量"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="最小包装量" prop="minPackCap">
        <el-input
          v-model="queryParams.minPackCap"
          placeholder="请输入最小包装量"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="存储仓库" prop="storWarehouse">
        <el-input
          v-model="queryParams.storWarehouse"
          placeholder="请输入存储仓库"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="存储库区" prop="storArea">
        <el-input
          v-model="queryParams.storArea"
          placeholder="请输入存储库区"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="存储库位" prop="storLoca">
        <el-input
          v-model="queryParams.storLoca"
          placeholder="请输入存储库位"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="安全库存" prop="safetyStock">
        <el-input
          v-model="queryParams.safetyStock"
          placeholder="请输入安全库存"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="库存下限" prop="storDownLimit">
        <el-input
          v-model="queryParams.storDownLimit"
          placeholder="请输入库存下限"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="库存上限" prop="storUpLimit">
        <el-input
          v-model="queryParams.storUpLimit"
          placeholder="请输入库存上限"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="溢库仓库" prop="ykWarehous">
        <el-input
          v-model="queryParams.ykWarehous"
          placeholder="请输入溢库仓库"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="发货地址" prop="sendWarehous">
        <el-input
          v-model="queryParams.sendWarehous"
          placeholder="请输入发货地址"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="收货地址" prop="shipperAddress">
        <el-input
          v-model="queryParams.shipperAddress"
          placeholder="请输入收货地址"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="发货仓库下架" prop="sendWaraShelve">
        <el-input
          v-model="queryParams.sendWaraShelve"
          placeholder="请输入发货仓库下架"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="发货仓库组托" prop="sendWaraSupport">
        <el-input
          v-model="queryParams.sendWaraSupport"
          placeholder="请输入发货仓库组托"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="发货仓库排序" prop="sendWaraSort">
        <el-input
          v-model="queryParams.sendWaraSort"
          placeholder="请输入发货仓库排序"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="发货仓库组车" prop="sendWaraZc">
        <el-input
          v-model="queryParams.sendWaraZc"
          placeholder="请输入发货仓库组车"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="运输转运" prop="transportation">
        <el-input
          v-model="queryParams.transportation"
          placeholder="请输入运输转运"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="园区排队" prop="parkLine">
        <el-input
          v-model="queryParams.parkLine"
          placeholder="请输入园区排队"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="园区门禁" prop="parkMj">
        <el-input
          v-model="queryParams.parkMj"
          placeholder="请输入园区门禁"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="园区入园" prop="parkInto">
        <el-input
          v-model="queryParams.parkInto"
          placeholder="请输入园区入园"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="收货排队" prop="goodsLine">
        <el-input
          v-model="queryParams.goodsLine"
          placeholder="请输入收货排队"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="收货卸车" prop="goodsUnload">
        <el-input
          v-model="queryParams.goodsUnload"
          placeholder="请输入收货卸车"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="器具装车" prop="equipLoad">
        <el-input
          v-model="queryParams.equipLoad"
          placeholder="请输入器具装车"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="专车发运" prop="carShip">
        <el-input
          v-model="queryParams.carShip"
          placeholder="请输入专车发运"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['sales:transportNode:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['sales:transportNode:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['sales:transportNode:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['sales:transportNode:export']"
        >导出</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
            type="info"
            plain
            icon="el-icon-upload2"
            size="mini"
            @click="handleImport"
        >导入</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="transportNodeList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="主键" align="center" prop="id" />
      <el-table-column label="公司代码" align="center" prop="factoryCode" />
      <el-table-column label="公司名称" align="center" prop="factoryName" />
      <el-table-column label="WMS子图号" align="center" prop="wmsChildNo" />
      <el-table-column label="子图号" align="center" prop="itemChildNo" />
      <el-table-column label="物料号" align="center" prop="materialNo" />
      <el-table-column label="名称" align="center" prop="itemName" />
      <el-table-column label="公司代码" align="center" prop="manCode" />
      <el-table-column label="公司名称" align="center" prop="manName" />
      <el-table-column label="物料正式属性" align="center" prop="materialFormAttr" />
      <el-table-column label="物料属性" align="center" prop="materialAttr" />
      <el-table-column label="物料大类号" align="center" prop="materialCategory" />
      <el-table-column label="送货包装类型" align="center" prop="delPackageType" />
      <el-table-column label="送货包装编码" align="center" prop="delPackageCode" />
      <el-table-column label="物料图片" align="center" prop="materialPhoto" />
      <el-table-column label="物料尺寸" align="center" prop="materialSize" />
      <el-table-column label="包装容量" align="center" prop="pacCapacity" />
      <el-table-column label="最小包装量" align="center" prop="minPackCap" />
      <el-table-column label="存储仓库" align="center" prop="storWarehouse" />
      <el-table-column label="存储库区" align="center" prop="storArea" />
      <el-table-column label="存储库位" align="center" prop="storLoca" />
      <el-table-column label="安全库存" align="center" prop="safetyStock" />
      <el-table-column label="库存下限" align="center" prop="storDownLimit" />
      <el-table-column label="库存上限" align="center" prop="storUpLimit" />
      <el-table-column label="溢库仓库" align="center" prop="ykWarehous" />
      <el-table-column label="发货地址" align="center" prop="sendWarehous" />
      <el-table-column label="收货地址" align="center" prop="shipperAddress" />
      <el-table-column label="发货仓库下架" align="center" prop="sendWaraShelve" />
      <el-table-column label="发货仓库组托" align="center" prop="sendWaraSupport" />
      <el-table-column label="发货仓库排序" align="center" prop="sendWaraSort" />
      <el-table-column label="发货仓库组车" align="center" prop="sendWaraZc" />
      <el-table-column label="运输转运" align="center" prop="transportation" />
      <el-table-column label="园区排队" align="center" prop="parkLine" />
      <el-table-column label="园区门禁" align="center" prop="parkMj" />
      <el-table-column label="园区入园" align="center" prop="parkInto" />
      <el-table-column label="收货排队" align="center" prop="goodsLine" />
      <el-table-column label="收货卸车" align="center" prop="goodsUnload" />
      <el-table-column label="器具装车" align="center" prop="equipLoad" />
      <el-table-column label="专车发运" align="center" prop="carShip" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['sales:transportNode:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['sales:transportNode:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改运输节点管理对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="90px">
        <el-row :gutter="24">
          <el-col :span="12">
            <el-form-item label="公司代码" prop="factoryCode">
              <el-input v-model="form.factoryCode" placeholder="请输入公司代码" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="公司名称" prop="factoryName">
              <el-input v-model="form.factoryName" placeholder="请输入公司名称" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="WMS子图号" prop="wmsChildNo">
              <el-input v-model="form.wmsChildNo" placeholder="请输入WMS子图号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="子图号" prop="itemChildNo">
              <el-input v-model="form.itemChildNo" placeholder="请输入子图号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="物料号" prop="materialNo">
              <el-input v-model="form.materialNo" placeholder="请输入物料号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="名称" prop="itemName">
              <el-input v-model="form.itemName" placeholder="请输入名称" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="公司代码" prop="manCode">
              <el-input v-model="form.manCode" placeholder="请输入公司代码" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="公司名称" prop="manName">
              <el-input v-model="form.manName" placeholder="请输入公司名称" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="物料正式属性" prop="materialFormAttr">
              <el-input v-model="form.materialFormAttr" placeholder="请输入物料正式属性" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="物料属性" prop="materialAttr">
              <el-input v-model="form.materialAttr" placeholder="请输入物料属性" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="物料大类号" prop="materialCategory">
              <el-input v-model="form.materialCategory" placeholder="请输入物料大类号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="送货包装编码" prop="delPackageCode">
              <el-input v-model="form.delPackageCode" placeholder="请输入送货包装编码" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="物料图片" prop="materialPhoto">
              <el-input v-model="form.materialPhoto" placeholder="请输入物料图片" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="物料尺寸" prop="materialSize">
              <el-input v-model="form.materialSize" placeholder="请输入物料尺寸" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="包装容量" prop="pacCapacity">
              <el-input v-model="form.pacCapacity" placeholder="请输入包装容量" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="最小包装量" prop="minPackCap">
              <el-input v-model="form.minPackCap" placeholder="请输入最小包装量" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="存储仓库" prop="storWarehouse">
              <el-input v-model="form.storWarehouse" placeholder="请输入存储仓库" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="存储库区" prop="storArea">
              <el-input v-model="form.storArea" placeholder="请输入存储库区" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="存储库位" prop="storLoca">
              <el-input v-model="form.storLoca" placeholder="请输入存储库位" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="安全库存" prop="safetyStock">
              <el-input v-model="form.safetyStock" placeholder="请输入安全库存" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="库存下限" prop="storDownLimit">
              <el-input v-model="form.storDownLimit" placeholder="请输入库存下限" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="库存上限" prop="storUpLimit">
              <el-input v-model="form.storUpLimit" placeholder="请输入库存上限" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="溢库仓库" prop="ykWarehous">
              <el-input v-model="form.ykWarehous" placeholder="请输入溢库仓库" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="发货地址" prop="sendWarehous">
              <el-input v-model="form.sendWarehous" placeholder="请输入发货地址" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="收货地址" prop="shipperAddress">
              <el-input v-model="form.shipperAddress" placeholder="请输入收货地址" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="发货仓库下架" prop="sendWaraShelve">
              <el-input v-model="form.sendWaraShelve" placeholder="请输入发货仓库下架" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="发货仓库组托" prop="sendWaraSupport">
              <el-input v-model="form.sendWaraSupport" placeholder="请输入发货仓库组托" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="发货仓库排序" prop="sendWaraSort">
              <el-input v-model="form.sendWaraSort" placeholder="请输入发货仓库排序" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="发货仓库组车" prop="sendWaraZc">
              <el-input v-model="form.sendWaraZc" placeholder="请输入发货仓库组车" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="运输转运" prop="transportation">
              <el-input v-model="form.transportation" placeholder="请输入运输转运" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="园区排队" prop="parkLine">
              <el-input v-model="form.parkLine" placeholder="请输入园区排队" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="园区门禁" prop="parkMj">
              <el-input v-model="form.parkMj" placeholder="请输入园区门禁" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="园区入园" prop="parkInto">
              <el-input v-model="form.parkInto" placeholder="请输入园区入园" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="收货排队" prop="goodsLine">
              <el-input v-model="form.goodsLine" placeholder="请输入收货排队" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="收货卸车" prop="goodsUnload">
              <el-input v-model="form.goodsUnload" placeholder="请输入收货卸车" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="器具装车" prop="equipLoad">
              <el-input v-model="form.equipLoad" placeholder="请输入器具装车" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="专车发运" prop="carShip">
              <el-input v-model="form.carShip" placeholder="请输入专车发运" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
      <el-upload
          ref="upload"
          :limit="1"
          accept=".xlsx, .xls"
          :headers="upload.headers"
          :action="upload.url + '?updateSupport=' + upload.updateSupport"
          :disabled="upload.isUploading"
          :on-progress="handleFileUploadProgress"
          :on-success="handleFileSuccess"
          :auto-upload="false"
          drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        <div class="el-upload__tip text-center" slot="tip">
          <!--  <div class="el-upload__tip" slot="tip">
              <el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的用户数据
            </div>-->
          <span>仅允许导入xls、xlsx格式文件。</span>
          <el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;" @click="importTemplate">下载模板</el-link>
        </div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listTransportNode, getTransportNode, delTransportNode, addTransportNode, updateTransportNode } from "@/api/sales/transportNode";
import {getToken} from "@/utils/auth";
export default {
  name: "TransportNode",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 运输节点管理表格数据
      transportNodeList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        factoryCode: null,
        factoryName: null,
        wmsChildNo: null,
        itemChildNo: null,
        materialNo: null,
        itemName: null,
        manCode: null,
        manName: null,
        materialFormAttr: null,
        materialAttr: null,
        materialCategory: null,
        delPackageType: null,
        delPackageCode: null,
        materialPhoto: null,
        materialSize: null,
        pacCapacity: null,
        minPackCap: null,
        storWarehouse: null,
        storArea: null,
        storLoca: null,
        safetyStock: null,
        storDownLimit: null,
        storUpLimit: null,
        ykWarehous: null,
        sendWarehous: null,
        shipperAddress: null,
        sendWaraShelve: null,
        sendWaraSupport: null,
        sendWaraSort: null,
        sendWaraZc: null,
        transportation: null,
        parkLine: null,
        parkMj: null,
        parkInto: null,
        goodsLine: null,
        goodsUnload: null,
        equipLoad: null,
        carShip: null
      },
      upload: {
        // 是否显示弹出层
        open: false,
        // 弹出层标题
        title: "导入`transportNode`信息",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/sales/transportNode/importData"
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询运输节点管理列表 */
    getList() {
      this.loading = true;
      listTransportNode(this.queryParams).then(response => {
        this.transportNodeList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        factoryCode: null,
        factoryName: null,
        wmsChildNo: null,
        itemChildNo: null,
        materialNo: null,
        itemName: null,
        manCode: null,
        manName: null,
        materialFormAttr: null,
        materialAttr: null,
        materialCategory: null,
        delPackageType: null,
        delPackageCode: null,
        materialPhoto: null,
        materialSize: null,
        pacCapacity: null,
        minPackCap: null,
        storWarehouse: null,
        storArea: null,
        storLoca: null,
        safetyStock: null,
        storDownLimit: null,
        storUpLimit: null,
        ykWarehous: null,
        sendWarehous: null,
        shipperAddress: null,
        sendWaraShelve: null,
        sendWaraSupport: null,
        sendWaraSort: null,
        sendWaraZc: null,
        transportation: null,
        parkLine: null,
        parkMj: null,
        parkInto: null,
        goodsLine: null,
        goodsUnload: null,
        equipLoad: null,
        carShip: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加运输节点管理";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getTransportNode(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改运输节点管理";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateTransportNode(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addTransportNode(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除数据？').then(function() {
        return delTransportNode(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('sales/transportNode/export', {
        ...this.queryParams
      }, `transportNode_${new Date().getTime()}.xlsx`)
    },
    /** 导入按钮操作 */
    handleImport() {
      this.upload.title = "运输节点管理导入";
      this.upload.open = true;
    },
    /** 下载模板操作 */
    importTemplate() {
      this.download('sales/transportNode/importTemplate', {
      }, `运输节点管理模板.xlsx`)
    },
    // 文件上传中处理
    handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true;
    },
    // 文件上传成功处理
    handleFileSuccess(response, file, fileList) {
      this.upload.open = false;
      this.upload.isUploading = false;
      this.$refs.upload.clearFiles();
      this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true });
      this.getList();
    },
    // 提交上传文件
    submitFileForm() {
      this.$refs.upload.submit();
    },
  }
};
</script>
